<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>广告列表</title>
	<hdjs />
	<js file='__PUBLIC__/js/mod.base.js' />
	<css file='__PUBLIC__/Css/mod.base.css' />
	<style type="text/css">
		.search{
			border: 1px solid #FFBE7A;
			background: none repeat scroll 0 0 #FFFCED;
			line-height: 20px;
			padding: 8px 10px;
		}
		.red{
			color:red;
		}
	</style>
</head>
<body>
	<div class="wrap">

		<form action="{:U('Ad/index')}" class="hd-form" method="get" >
			
			<input type="hidden" name="sta" value="{$Think.get.sta}" />
			<div class="search">

				<!-- 添加时间：
				<input id="begin_time" placeholder="开始时间" readonly="readonly" class="hd-w80" type="text" value="<if condition='isset($_GET["search_begin_time"])'>{$Think.get.search_begin_time}</if>" name="search_begin_time">
				<script>
					$('#begin_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				-
				<input id="end_time" placeholder="结束时间" readonly="readonly" class="hd-w80" type="text" value="<if condition='isset($_GET["search_end_time"])'>{$Think.get.search_end_time}</if>" name="search_end_time">
				<script>
					$('#end_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				&nbsp;&nbsp;&nbsp; -->
				<!-- <select name="search_type" class="hd-w100">
					<option value="1" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 1">selected='selected'</if>>名称</option>
					<option value="2" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 2">selected='selected'</if>>用户名</option>
					<option value="3" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 3">selected='selected'</if>>用户uid</option>
				</select>&nbsp;&nbsp;&nbsp; -->
				<select name="psid" class="hd-hd-w100">
					<option value="0">所有位置</option>
					<foreach name='position' item='v'>
					<option value="{$v.psid}" <if condition="isset($_GET['psid']) && $_GET['psid'] eq $v['psid']">selected='selected'</if>>{$v.position_name}</option>
					</foreach>
				</select>&nbsp;&nbsp;&nbsp;
				关键字：
				<input class="hd-w200" type="text" placeholder="请输入关键字..." value="<if condition='isset($_GET["search_keyword"])'>{$Think.get.search_keyword}</if>" name="search_keyword">

				
				<button class="hd-btn hd-btn-xm" type="submit">
					搜索
				</button>

				<button class="hd-btn hd-btn-xm" type="button" onclick="location.href='{:U('Ad/index')}'">
					查看所有广告
				</button>
			</div>
		</form>
		<form action="{:U('Ad/update')}" method="post" id='list' class='hd-form'>
				<div class="hd-menu-list">
					<ul>
						<li <if condition='$_GET["sta"] eq 2'>class="active"</if>>
							<a href="{:U('Ad/index')}" >
								广告列表
							</a>
						</li>
						<li <if condition='$_GET["sta"] eq 1'>class="active"</if>>
							<a href="{:U('Ad/index',array('sta'=>1))}" <>
								未审核
							</a>
						</li>
						<li>
							<a href="{:U('Ad/add')}">
								添加
							</a>
						</li>
					</ul>
				</div>
				<table class="hd-table hd-table-list hd-form">
						<thead>
						<tr>
							<td class="hd-hd-w30">
							<input type="checkbox" class="select_all"/>
							</td>
							<td class="hd-w30">AID</td>
							<td class="hd-w30">PSID</td>
							<td class="hd-w50">位置</td>
							<td class="hd-w50">排序</td>
							<td>名称</td>
							<td>图片</td>
							<td class="hd-w80">状态</td>
							<td class="hd-w80">作者</td>
							<td class="hd-w100">添加时间</td>
							<td class="hd-w100">操作</td>
						</tr>
						</thead>
						<if condition='$data'>
						<foreach name='data' item='v'>
						<tr>
							<td>
							<input type="checkbox" name="aid[{$v.aid}]" value="{$v.aid}"/>
							</td>
							<td>{$v.aid}</td>
							<td>{$v.psid}</td>
							<td>{$v.position_name}</td>
							<td>
							<input type="text" class="hd-w30" value="{$v.sort}" name="list_order[{$v.aid}]"/>
							</td>
							<td>{$v.name}</td>
							<td><img src="{$v.pic}" alt=""  width="100" height='30' /></td>
							<td>{$v.verifystate}</td>
							<td>{$v.username}</td>
							<td>{$v.addtime}</td>
							<td>

							<a href="{:U('Ad/edit',array('aid'=>$v['aid']))}">
								修改
							</a>
							<span class="line">|</span>
							<a href="javascript:var del='{:U('Ad/del',array('aid'=>$v['aid'],'psid'=>$v['position_psid']))}';hd_modal_confirm('确认删除吗？',del)">
								删除
							</a></td>
						</tr>
						</foreach>
						<tr><td colspan="11" class="page">{$page}</td></tr>
						<else/>
						<tr><td colspan="11">没有找到符合的记录</td></tr>
						</if>

					</table>
				<div class="h60"></div>
		</form>
	</div>

	<div class="position-bottom">
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(1)" value='全选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(0)" value='反选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="update(1)" value="更改排序"  />
		<input class="hd-btn hd-btn-xm" type="button" value="审核" onclick="update(2)" >
		<input class="hd-btn hd-btn-xm" type="button" value="取消审核" onclick="update(3)" >
		<input class="hd-btn hd-btn-xm" type="button" value="删除" onclick="update(4)" >
	</div>
<script>
//更新
function update(type) {
    //栏目检测
    var html;
    switch(parseInt(type))
	{
		case 1:
		type='排序';
		html='<input type="hidden" name="order" />';
		break;
		case 2:type='审核';
		html='<input type="hidden" name="check" />';
		break;
		case 3:type='取消审核';
		html='<input type="hidden" name="cancel_check" />';
		break;
		case 4:type='删除';
		html='<input type="hidden" name="del_check" />';
		break;
	}
    if ($("input[type='checkbox']:checked").length == 0) 
    {
        alert('没有信息用于'+type);
        return false;
    }
    $('#list').append(html);
  	$('#list').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>
</body>
</html>